﻿using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.Windows;
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Input;
using System.Windows.Media.Imaging;

namespace RibbonCreator
{
    class Images
    {
        public static double m_DpiScale = 1.0;

        public static BitmapImage GetBitmap(Bitmap image, uint l)
        {
            MemoryStream stream = new MemoryStream();
            image.Save(stream, ImageFormat.Png);
            BitmapImage bmp = new BitmapImage();
            bmp.BeginInit();
            bmp.StreamSource = stream;
            bmp.DecodePixelHeight = (int)(l * m_DpiScale);
            bmp.DecodePixelWidth = (int)(l * m_DpiScale);
            bmp.EndInit();
            return bmp;
        }
    }

    class RibbonButtonCmdHandle : ICommand
    {
        public event EventHandler CanExecuteChanged;

        public bool CanExecute(object parameter)
        {
            return true;
        }

        public void Execute(object parameter)
        {
            if (parameter is RibbonButton)
            {
                RibbonButton ribbonButton = parameter as RibbonButton;
                Application.DocumentManager.MdiActiveDocument.SendStringToExecute((string)ribbonButton.CommandParameter, true, false, true);
            }
        }
    }
}
